import request from './request'

export default {
    getBannerList(type) {
        return request({
            url: '/admin/front/bannerList',
            method: 'get',
            params: {type: type}
        })
    },
    getComponentList(type) {
        return request({
            url: '/admin/front/extendComponentList',
            method: 'get',
            params: {type: type}
        })
    },
    getSourceCodeList() {
        return request({
            url: '/admin/front/sourceCodeList',
            method: 'get'
        })
    },
    getOnlineDemoList() {
        return request({
            url: '/admin/front/onlineShowList',
            method: 'get'
        })
    },
    getSpaceDocumentByName(name) {
        return request({
            method: 'get',
            url: '/admin/spaceDocument/getSpaceDocumentByName',
            params: {"name": name}
        })
    },
    getCatalogue(type) {
        return request({
            url: '/admin/front/getIndexSpaceDirectoryTree',
            method: 'get',
            params: {type: type}
        })
    },
    getDirectoryTreeSelect() {
        return request({
            url: '/admin/front/getDirectorySelectTree',
            method: 'get'
        })
    },
    getDynamicRecord(page) {
        return request({
            url: '/admin/front/getDynamicRecord',
            method: 'get',
            params: {"page": page}
        })
    },
    getPersonCount() {
        return request({
            url: '/admin/front/getPersonCount',
            method: 'get'
        })
    },
    getPersonData() {
        return request({
            url: '/admin/front/getPersonalData',
            method: 'get'
        })
    },
    getSpaceAvatar() {
        return request({
            url: '/admin/front/getSpaceAvatar',
            method: 'get'
        })
    },
    getPersonalRecent(recordType, documentName, page) {
        return request({
            url: '/admin/front/getPersonalRecent',
            method: 'get',
            params: {
                "recordType": recordType,
                "documentName": documentName,
                "page": page
            }
        })
    },
    addSpaceDocument(data) {
        return request({
            url: '/admin/front/addSpaceDocument',
            method: 'post',
            data: data
        })
    },
    getPersonalCollection(documentName, page) {
        return request({
            url: '/admin/front/getCollection',
            method: 'get',
            params: {
                "documentName": documentName,
                "page": page
            }
        })
    },
    getMineUpload(documentName, page) {
        return request({
            url: '/admin/front/getMineUpload',
            method: 'get',
            params: {
                "documentName": documentName,
                "page": page
            }
        })
    },
    //文件下载排行榜
    getDownloadRank(timeSpan, currentPage) {
        return request({
            url: '/admin/front/getDownloadRank',
            method: 'get',
            params: {
                "timeSpan": timeSpan,
                "currentPage": currentPage
            }
        })
    },
    //文件阅读排行榜
    getReadRank(timeSpan, currentPage) {
        return request({
            url: '/admin/front/getReadRank',
            method: 'get',
            params: {
                "timeSpan": timeSpan,
                "currentPage": currentPage
            }
        })
    },
    //文件上传排行榜
    getUploadRank(timeSpan, startTime, endTime) {
        return request({
            url: '/admin/front/getUploadRank',
            method: 'get',
            params: {
                "timeSpan": timeSpan,
                "startTime": startTime,
                "endTime": endTime
            }
        })
    },
    //文件类别统计
    getSpaceDocumentStatInfo() {
        return request({
            url: '/admin/front/getStatInfo',
            method: 'get'
        })
    },
    //获取文档类型
    getDocumentType() {
        return request({
            url: '/admin/front/getDocumentType',
            method: 'get'
        })
    },
    //获取文件夹类型类型
    getDirectoryType() {
        return request({
            url: '/admin/front/getDirectoryType',
            method: 'get'
        })
    },
    //新增文件夹
    addSpaceDirectory(data) {
        return request({
            url: '/admin/front/addSpaceDirectory',
            method: 'post',
            data: data
        })
    },
    getDirectorySelectTree() {
        return request({
            url: '/admin/front/getDirectorySelectTree',
            method: 'get',
        })
    },
    getParentNode(docId, directoryId) {
        return request({
            url: '/admin/front/getParentNode',
            method: 'get',
            params: {docId: docId, directoryId: directoryId}
        })
    },
    getSpaceDocDetail(id) {
        return request({
            url: '/admin/front/getSpaceDocDetail',
            method: 'get',
            params: {spaceDocumentId: id}
        })
    },
    //下载文件
    downloadFile(spaceDocId) {
        return request({
            url: '/admin/front/downloadFile',
            method: 'get',
            params: {
                'spaceDocId': spaceDocId
            },
            timeout: 120000
        })
    },
    removeSpaceDirectory(id) {
        return request({
            url: '/admin/front/removeSpaceDirectory/' + id,
            method: 'delete',
        })
    },
    getEchoDirectory(id) {
        return request({
            url: '/admin/front/getEchoDirectory',
            method: 'get',
            params: {
                'id': id
            }
        })
    },
    updateSpaceDirectory(data) {
        return request({
            url: '/admin/front/updateSpaceDirectory',
            method: 'put',
            data: data
        })
    },
    addCollection(id) {
        return request({
            url: '/admin/front/addCollection',
            method: 'post',
            params: {
                'documentId': id
            }
        })
    },
    removeCollection(id) {
        return request({
            url: '/admin/front/removeCollection',
            method: 'post',
            params: {
                'documentId': id
            }
        })
    },
    moveDirectory(id,oldParentId, parentId, type,oldOrderNum) {
        return request({
            url: '/admin/front/moveDirectory',
            method: 'post',
            params: {
                'id': id,
                'oldParentId': oldParentId,
                'parentId': parentId,
                'type': type,
                'oldOrderNum':oldOrderNum
            }
        })
    },
    getFirstIndexSpaceDirectoryTree(type) {
        return request({
            url: '/admin/front/getFirstIndexSpaceDirectoryTree',
            method: 'get',
            params: {type: type}
        })
    },
    spaceSearch(searchItem, type) {
        return request({
            url: '/admin/front/spaceSearch',
            method: 'get',
            params: {'searchItem': searchItem, 'type': type}
        })
    },
    getDirectoryFirstDoc(directoryId) {
        return request({
            url: '/admin/front/getDirectoryFirstDoc/' + directoryId,
            method: 'get'
        })
    },
    getImagesUnderDirectory(docId) {
        return request({
            url: '/admin/front/getImagesUnderDirectory',
            method: 'get',
            params: {docId: docId}
        })
    },
    checkFolderExist(folderName, id) {
        return request({
            url: '/admin/front/checkFolderExist',
            method: 'get',
            params: {
                folderName: folderName,
                id: id
            }
        })
    },
    moveDirectoryChangeOrderNum(id, oldNum, newNum,oldParentId,newParentId,mode) {
        return request({
            url: '/admin/front/moveDirectoryChangeOrderNum',
            method: 'get',
            params: {
                id: id,
                oldNum: oldNum,
                newNum: newNum,
                oldParentId:oldParentId,
                newParentId:newParentId,
                mode: mode
            }
        })
    },
    checkMDEditPermission(docId) {
        return request({
                url: '/admin/front/checkMDEditPermission',
                method: 'get',
                params: {docId: docId}
            }
        )
    },
    addMarkdown(file, parentId, type) {
        return request({
                url: '/admin/front/addMarkdown',
                method: 'post',
                data: {
                    file: file,
                    type: type,
                    parentId: parentId
                },
                timeout: 30000,
                headers: {
                    'Content-Type': 'multipart/form-data'
                }
            }
        )
    },
    getSpaceDirectoryByParentId(parentId) {
        return request({
            url: '/admin/front/getSpaceDirectoryByParentId',
            method: 'get',
            params: {parentId: parentId}
        })
    },
    getMaxOrder(type,parentId){
        return request({
            url:"/admin/front/getMaxOrder",
            method:'get',
            params:{
                type:type,

                parentId: parentId}
        })
    },
    getUpdateRecordList(){
        return request({
            url:"/front/updateRecord",
            method:'get'
        })
    },
    addUpdateRecord(data){
        return request({
            url:"/front/updateRecord",
            method:'put',
            data:data
        })
    },
    getUpdateRecordById(id){
        return request({
            url:"/front/updateRecord/"+id,
            method:'get'
        })
    },
    updateUpdateRecord(data){
        return request({
            url:"/front/updateRecord",
            method:'post',
            data:data
        })
    },
    getLatestVersion(){
        return request({
            url:"/front/updateRecord/getVersion/latest",
            method:'get',
        })
    },
    getSysVersionList(){
        return request({
            url:"/system/version/list",
            method:'get',
        })
    }
}

